package com.daoImpl;

import com.bean.Comment;
import com.dao.BasicDAO;
import com.dao.CommentDAO;

import java.util.List;

/**
 * @author 徐洲
 * @version 1.0
 */
public class CommentDAOImpl extends BasicDAO<Comment> implements CommentDAO {
    @Override
    public List<Comment> getComments(Object article_id){
        String sql = "SELECT * FROM commentview WHERE article_id = ? ORDER BY create_time DESC;";
        return queryMulti(sql, Comment.class, article_id);
    }

    @Override
    public boolean addComment(String article_id, String user_id, String content) {
        String sql = "INSERT into `comment`(article_id, user_id, content) VALUES (?, ?, ?);";
        Integer integer = update(sql, article_id, user_id, content);
        if (integer == null) return false;
        return integer > 0;
    }
}
